package com.souku.finance.application.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.souku.finance.application.R;
import com.souku.finance.application.bean.CurrentDetailedBean;
import com.souku.finance.application.utils.MyTextUtil;

import java.util.List;

/**
 * Created by Android on 2016/12/20.
 */

public class CurrentDetailedAdapter extends BaseAdapter {

    private List<CurrentDetailedBean.ListBean> list;

    public CurrentDetailedAdapter(List<CurrentDetailedBean.ListBean> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder viewHolder = null;
        if (view == null || !(view.getTag() instanceof ViewHolder)) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_currentdetailed, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        CurrentDetailedBean.ListBean bean=list.get(position);
        viewHolder.tvDate.setText(MyTextUtil.changeTimeFormat(bean.getGmtCreated()));
        viewHolder.tvInterest.setText(MyTextUtil.setMoneyToElement(bean.getInterest()));
        return view;
    }


    static class ViewHolder {
        protected TextView tvInterest;
        protected TextView tvDate;

        ViewHolder(View rootView) {
            initView(rootView);
        }

        private void initView(View rootView) {
            tvInterest = (TextView) rootView.findViewById(R.id.tv_interest);
            tvDate = (TextView) rootView.findViewById(R.id.tv_date);
        }
    }
}
